const state = {
  token: '',
  tabBotName: uni.getStorageSync('tabBotName') || null,
  pageData: uni.getStorageSync('pageData') || null,
  CartGoodsNum: 0,
  tabsList: [
    {
      pagePath: 'pages/index/index',
      iconPath: '/static/imgs/12.png',
      selectedIconPath: '/static/imgs/11.png',
      text: '首页',
      pageName: 'HomePage',
    },
    {
      pagePath: 'pages/cart/cart',
      iconPath: '/static/imgs/22.png',
      selectedIconPath: '/static/imgs/21.png',
      text: '购物车',
      pageName: 'CartPage',
    },
    {
      pagePath: 'pages/catalog/catalog',
      iconPath: '/static/imgs/32.png',
      selectedIconPath: '/static/imgs/31.png',
      text: '客服',
      pageName: 'CatalogPage',
    },
    {
      pagePath: 'pages/ucenter/index/index',
      iconPath: '/static/imgs/42.png',
      selectedIconPath: '/static/imgs/41.png',
      text: '我的',
      pageName: 'MinePage',
    },
  ],
}

const mutations = {
  set_token(state, data) {
    state.token = data
  },
  set_pageData(state, data) {
    state.pageData = data
  },
  set_tabBotName(state, data) {
    state.tabBotName = data
  },
  set_CartGoodsNum(state, data) {
    state.CartGoodsNum = data
  },
}

const actions = {
  on_CartGoodsNum({ commit }, data) {
    commit('set_CartGoodsNum', data)
  },
  on_token({ commit }, data) {
    commit('set_token', data)
  },
  on_pageData({ commit }, data) {
    commit('set_pageData', data)
    uni.setStorageSync('pageData', data)
  },
  on_tabBotName({ commit }, data) {
    commit('set_tabBotName', data)
    uni.setStorageSync('tabBotName', data)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
